//
// Created by lanlu on 2025/8/5.
//

#include <vector>
#include <iostream>
using namespace std;

class Solution {
public:
    int peopleAwareOfSecret(int n, int delay, int forget)
    {
        int MOD = 1e9 + 7;
        // dp[i]表示第i天新增的人数
        //   已经知道秘密超过delay天  i - delay
        //   还没忘记秘密 i - forget + 1
        vector<long long> dp(n + 1, 0);
        dp[1] = 1;
        for (int i = 2; i <= n; i++)
        {
            // 能够分享秘密的范围
            // n = 6, delay = 2, forget = 4
            //    i=4           i-forget+1=1  i-delay=2
            int start = max(1, i - forget + 1);  // 未忘记秘密的起始天
            int end = i - delay; // 已过delay天可以分享的 截止天
            if (end >= start)
            {
                for (int j = start; j <= end; j++)
                {
                    dp[i] = (dp[i] + dp[j]) % MOD;
                }
            }
        }

        // 计算第n天 有效知道秘密的人数  [n-forget+1,n]
        long long result = 0;
        for (int i = max(1, n - forget + 1); i <= n; i++)
        {
            result = (result + dp[i]) % MOD;
        }
        return (int)result;
    }
};

int main()
{
    Solution s;
    int n = 6;
    int delay = 2;
    int forget = 4;
    int res = s.peopleAwareOfSecret(n, delay, forget);
    cout << res << endl;
    return 0;
}
